package com.atguigu.lease.common.redis;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;

/**
 * @ClassName: RedisConfiguration
 * @Description: 自定义RedisTemplate
 * @Author: yangchengbao
 * @Create: 2025/1/11 13:04
 * @Version: 1.0
 */
@Configuration
public class RedisConfiguration {

    /**
     * @param redisConnectionFactory
     * @Desceription: 自定义RedisTemplate
     * @Return: org.springframework.data.redis.core.RedisTemplate<java.lang.String, java.lang.Object>
     * @Author: yangchengbao
     * @Date: 2025-01-11 13:01:40
     */
    @Bean
    public RedisTemplate<String, Object> stringObjectRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, Object> template = new RedisTemplate<>();
        template.setConnectionFactory(redisConnectionFactory);
        template.setKeySerializer(RedisSerializer.string());
        template.setValueSerializer(RedisSerializer.java());
        return template;
    }
}
